package com.lk.websocketdemo.controller;

import com.lk.websocketdemo.core.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @Author: 蔡翔
 * @Date: 2019/7/17 18:29
 * @Version 1.0
 */
@RestController
public class testController {
    @Autowired
    WebSocketServer webSocketServer;

    @GetMapping("/to2")
    public void test() throws IOException {
        webSocketServer.sendtoUser("hello 1","db445aaf-6b6d-4e69-84d3-e5b84de72af81589422094154");
    }
    @GetMapping("/to1")
    public void test2() throws IOException {
        webSocketServer.sendtoAll("hello all");
    }


    @GetMapping("/getUniqueCode")
    public String getUniqueCode() throws IOException {
        return webSocketServer.getUniqeId();
    }
}
